set(CMAKE_INCLUDE_CURRENT_DIR ON)

find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets)


set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)

file(GLOB_RECURSE sources *.cpp *.c)
file(GLOB_RECURSE headers *.h *.hpp *.inl)
file(GLOB_RECURSE uis *.ui)

add_executable(ModelView ${sources} ${headers} ${uis})

target_link_libraries(ModelView Qt5::Core Qt5::Gui Qt5::Widgets)

if (MSVC)
	macro(create_filter_by_dir src_dir)
		set_property(GLOBAL PROPERTY USE_FOLDERS ON)
		foreach(file ${ARGN})
			get_filename_component(PARENT_DIR "${file}" DIRECTORY)
			string(REPLACE ${src_dir} "" GROUP "${PARENT_DIR}")
			string(REPLACE "/" "\\" GROUP "${GROUP}")
			source_group("${GROUP}" FILES "${file}")
		endforeach()
	endmacro(create_filter_by_dir)
	create_filter_by_dir(${CMAKE_CURRENT_SOURCE_DIR} ${sources} ${headers} ${uis})
endif()
